package com.itqf.quartz;

import com.itqf.job.TimeJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * projectName: logandquartzgp8
 *
 * @author: 赵伟风
 * time: 2021/8/10 17:14
 * description: 每五秒触发一次
 */
public class CronJob {


    public static void main(String[] args) throws SchedulerException {


        //1.创建jobDetail
        JobDetail jobDetail = JobBuilder.newJob(TimeJob.class).build();

        //2.创建cronTrigger
        CronTrigger cronTrigger = TriggerBuilder.newTrigger().withSchedule(
                CronScheduleBuilder.cronSchedule("0/5 * * * * ? *")).build();

        //3.执行器触发
        StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
        Scheduler scheduler = stdSchedulerFactory.getScheduler();

        scheduler.scheduleJob(jobDetail, cronTrigger);

        scheduler.start();
    }
}
